/*******************************************************************************
 * Copyright (C) 2010 Chris Wroe
 * 
 * Modifications to the initial code base are copyright of their respective
 * authors, or their employers as appropriate.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307
 ******************************************************************************/

package uk.co.wroedevelopments.semanticworkbench.reasoner;

import org.neo4j.api.core.NeoService;
import org.neo4j.api.core.Node;
import org.neo4j.util.index.LuceneIndexService;
import org.xtext.example.semDsl.Concept;
import org.xtext.example.semDsl.Restriction;

import uk.co.wroedevelopments.semanticworkbench.store.AxiomType;
import uk.co.wroedevelopments.semanticworkbench.store.IKnowledgeBase;
import uk.co.wroedevelopments.semanticworkbench.store.OntologyChangeListener;

public class AxiomBuilder implements OntologyChangeListener {
	
	private IKnowledgeBase knowledgeBase;
	

	public AxiomBuilder(IKnowledgeBase kbStore) {
		this.knowledgeBase = kbStore;
	}


	
	

	public void conceptAdded(Concept concept, Node Node) {
		// TODO Auto-generated method stub

	}

	public void conjunctionAdded(Node conjunctionNode, Node nodeA, Node nodeB, boolean positive, boolean negative, Node superkindNode) {
		// create A [ B
		// Can't add it here don't have access to all the information
		// do now
		// create an axiom node with two sides
		// or just a direct subsumption relationship?
		// can get a relationship by its id. So could have an axiom node that has a property pointing to the relationship id
		//knowledgeBase.addSubsumptionAxiom();
		// if this is a pos only conjunction for A^B conjunction id
		if (positive) {
			knowledgeBase.addConceptInclusionAxiom(conjunctionNode,nodeA);
			knowledgeBase.addConceptInclusionAxiom(conjunctionNode,nodeB);
		}// add id [ A
		// add id [ B
		// if this is a pos/neg conjunction for A ^ B conjunction id
		// add id [ A
		// add id [ B
		// add A ^ B [ id
		if (negative) {
			knowledgeBase.addConjunctionAxiom(conjunctionNode, nodeA,nodeB);
		}
		
		
		
		
	}

	public void restrictionAdded(Node restictionNode, Node attributeNode, Node valueNode,boolean positive,boolean negative) {
		if (positive) {
			knowledgeBase.addPositiveExistentialAxiom(restictionNode, attributeNode, valueNode);
		}
		if (negative) {
			knowledgeBase.addNegativeExistentialAxiom(attributeNode, valueNode, restictionNode);
		}
		

	}

	public void newSubConceptAdded(Node childNode, Node parentNode) {
		knowledgeBase.addConceptInclusionAxiom(childNode, parentNode);

	}


	public void attributeAdded(Node attNode, Node parentNode) {
		knowledgeBase.addRoleInclusionAxiom(attNode, parentNode);
		
	}

}
